package com.huawei.hianalytics.ab.bc.ik.bc;

import android.content.Context;
import android.util.Pair;
import com.huawei.hianalytics.ab.ab.bc;
import com.huawei.hianalytics.ab.bc.cd.bc.de;
import com.huawei.hianalytics.ab.bc.ik.cd.ab;
import com.huawei.hianalytics.ab.bc.kl.ef;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class cd implements ab {
    private Context ab = bc.ik();
    private String bc;
    private String cd;
    private String de;

    public cd(String str, String str2, String str3) {
        this.bc = str;
        this.cd = str2;
        this.de = str3;
    }

    private void ab(String str, List<de> list) {
        Pair ab = ef.ab(str);
        new com.huawei.hianalytics.ab.bc.de.bc(list, (String) ab.first, (String) ab.second, this.de).ab();
    }

    public void run() {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("EventReportTask", "eventReportTask is running");
        boolean ab = com.huawei.hianalytics.ab.bc.kl.bc.ab(this.ab);
        if (ab) {
            com.huawei.hianalytics.ab.bc.ef.ab.bc("EventReportTask", "workKey is refresh,begin report all data");
            this.cd = "alltype";
        }
        Map ab2 = com.huawei.hianalytics.ab.bc.de.ef.ab(this.ab, this.bc, this.cd);
        if (ab2.size() == 0) {
            com.huawei.hianalytics.ab.bc.ef.ab.ab("EventReportTask", "no have events to report: tag:%s : type:%s", this.bc, this.cd);
            return;
        }
        for (Entry entry : ab2.entrySet()) {
            ab((String) entry.getKey(), (List) entry.getValue());
        }
        if ("alltype".equals(this.cd)) {
            com.huawei.hianalytics.ab.bc.ij.ab.ab(this.ab, "stat_v2_1", new String[0]);
            com.huawei.hianalytics.ab.bc.ij.ab.ab(this.ab, "cached_v2_1", new String[0]);
        } else {
            String ab3 = ef.ab(this.bc, this.cd);
            com.huawei.hianalytics.ab.bc.ij.ab.ab(this.ab, "stat_v2_1", ab3);
            com.huawei.hianalytics.ab.bc.ij.ab.ab(this.ab, "cached_v2_1", ab3);
        }
        if (ab) {
            com.huawei.hianalytics.ab.bc.ef.ab.bc("EventReportTask", "refresh local key");
            com.huawei.hianalytics.ab.bc.gh.bc.ab().bc();
            com.huawei.hianalytics.ab.bc.de.ab.ab().ab(com.huawei.hianalytics.ab.bc.de.ab.ab().bc());
        }
    }
}
